//
//  OrderDetaiABlViewCell.m
//  DMGME
//
//  Created by MC on 15/9/27.
//  Copyright (c) 2015年 GYP. All rights reserved.
//

#import "OrderDetaiABlViewCell.h"
#import "UIImageView+WebCache.h"
#import "OrderGoodsModel.h"
@implementation OrderDetaiABlViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code

        CGFloat width = [[UIScreen mainScreen] bounds].size.width;
        UIImageView *titleImg = [[UIImageView alloc] initWithFrame:CGRectMake(10, 5, 45, 60)];
        _titleImg = titleImg;
        titleImg.backgroundColor = [UIColor colorWithWhite:230/255.0 alpha:1];
        [self.contentView addSubview:titleImg];
        
        UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(75, 10, 160, 21)];
        _titleLabel = titleLabel;
        titleLabel.textColor = [UIColor grayColor];
        titleLabel.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:titleLabel];
        
        UILabel *sessionLabel = [[UILabel alloc] initWithFrame:CGRectMake(75, 45, 80, 21)];
        _sessionLabel = sessionLabel;
        sessionLabel.font = [UIFont systemFontOfSize:14];
        sessionLabel.textColor = [UIColor lightGrayColor];
        [self.contentView addSubview:sessionLabel];
        
        UILabel *priceLabel = [[UILabel alloc] initWithFrame:CGRectMake(width-65, 30, 75, 21)];
        _priceLabel = priceLabel;
        priceLabel.font = [UIFont systemFontOfSize:12];
        priceLabel.textColor = [UIColor blackColor];
        [self.contentView addSubview:priceLabel];
        
        UILabel *numLabel = [[UILabel alloc] initWithFrame:CGRectMake(width-65, 50, 30, 21)];
        _numLabel = numLabel;
        numLabel.font = [UIFont systemFontOfSize:13];
        numLabel.textColor = [UIColor lightGrayColor];
        [self.contentView addSubview:numLabel];
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        UIImageView *line = [[UIImageView alloc] initWithFrame:CGRectMake(0, 74, KWidth, 1)];
        line.backgroundColor = [UIColor lightGrayColor];
        line.alpha = 0.5;
        [self.contentView addSubview:line];

     
    }
    return self;
}
- (void)awakeFromNib {
    // Initialization code
}

-(void)setSubModel:(OrderGoodsModel *)subModel
{
    _subModel = subModel;
    _titleImg.image = [UIImage imageNamed:@"iv_defalut"];
    [_titleImg sd_setImageWithURL:[NSURL URLWithString:subModel.cover]];
    _titleLabel.text = subModel.title;
//    NSLog(@"period == %@ == %@",subModel.period,subModel.title);
    if (([subModel.period   isEqual: @""]||[subModel.period  isEqual: @"0"])) {
        _sessionLabel.hidden = YES;
        _titleImg.frame = CGRectMake(10, 10, 50, 50);
        _titleLabel.frame = CGRectMake(75, 10, 130, 21);
    }else
    {
    
        _sessionLabel.hidden = NO;
    _sessionLabel.text = [NSString stringWithFormat:@"%@期",subModel.period];
//        NSLog(@"=== %@  ==%@",_sessionLabel.text,_titleLabel.text );
        
    }
    _priceLabel.text =  [NSString stringWithFormat:@"￥%@",subModel.retail_price];
    _numLabel.text = [NSString stringWithFormat:@"x%@",subModel.num];
    
    

}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
